<script>

_h=h= Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var sWidth = parseInt((window.innerWidth > 0) ? window.innerWidth : screen.width);
if(sWidth>750){sWidth=750;}
var _rate=(sWidth/750);
$(function(){
$('.phonereg-t1').width(sWidth).height(_rate*578);
$('.phonereg-phone').width(_rate*440).height(_rate*70).css({"top":_rate*191, "left":_rate*242});
$('.phonereg-code').width(_rate*260).height(_rate*70).css({"top":_rate*280, "left":_rate*246});
$('.phonereg-yzbtn').width(_rate*200).height(_rate*80).css({"top":_rate*270, "left":_rate*510,'line-height':_rate*80+'px'});
$('.phonereg-btn').width(_rate*570).height(_rate*120).css({"top":_rate*400, "left":_rate*90});

$('.userreg-t1').width(sWidth).height(_rate*1006);
$('.userreg-phone').width(_rate*440).height(_rate*70).css({"top":_rate*210, "left":_rate*242});
$('.userreg-name').width(_rate*440).height(_rate*70).css({"top":_rate*371, "left":_rate*242});
$('.userreg-yu').width(_rate*240).height(_rate*70).css({"top":_rate*461, "left":_rate*442});
$('.userreg-yu2').width(_rate*240).height(_rate*70).css({"top":_rate*601, "left":_rate*442}); 
$('.userreg-c1').width(_rate*59).css({"top":_rate*698, "left":_rate*48});
$('.userreg-tiaokuan').width(_rate*320).height(_rate*90).css({"top":_rate*698, "left":_rate*348});
$('.userreg-btn').width(_rate*670).height(_rate*170).css({"top":_rate*801, "left":_rate*42});

 
wx.config({
    appId: '<?php echo $signPackage["appId"];?>',
    timestamp: <?php echo $signPackage["timestamp"];?>,
    nonceStr: '<?php echo $signPackage["nonceStr"];?>',
    signature: '<?php echo $signPackage["signature"];?>',
    jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData', 'showMenuItems', 'hideMenuItems']
});
wx.ready(function () {
		var _title='';
		var _link='http://climb-game.51wom.com/?f=<?php echo $openid; ?>';
		var _imgUrl='http://climb-game.51wom.com/images/64.jpg';
			wx.updateAppMessageShareData({
			    title: _title, 
			    desc: 'miaosu', 
			    link: _link, 
			    imgUrl: _imgUrl, 
			    success: function () {
			    }
			  })
			 wx.updateTimelineShareData({ 
                  title: 'miaosu', 
                  link: _link, 
                  imgUrl: _imgUrl, 
                  success: function () {
                  }
                });
			_bgm.play();
			_isPlay=true;
			$(".pBgm1").show();
			$(".pBgm2").hide();

}); 
window.setTimeout(function(){
  $.post("api/?c=pv", {op:'<?php echo $openid ?>',cookieid:_cookieId}, function(data){}, "json");
}, 700);

 
document.addEventListener("WeixinJSBridgeReady", function(){_bgm.play()}, false);


});


<?php if (2 == $gameStatus){ //还没开始 ?>
	$(".gonggaobox, .loginbox").hide();
    $(".activeNotStartbox").show();
    $(".endactiveChakangonggao").click(function(){
    	$(".activeNotStartbox").hide();
     });
<?php } ?>

<?php if (3 == $gameStatus){ //已结束 ?>
    $(".gonggaobox, .loginbox").hide();
    $(".endactivebox").show();
<?php } ?>

<?php if (empty($phone)){ ?>
  $(".gonggaobox").hide();
  $(".phonereg").show();
<?php }else{ ?>
window.setTimeout(function(){
  _setEveClick('gonggao');
}, 600);
<?php } ?>

//$(".gonggaobox").hide();
//$(".newrecordbox").show();


$('#userreg-d1').on('click', function () {
        weui.datePicker({
            start: 1990,
            end: 2025,
            onConfirm: function (result) {
               $('#userreg-d1').val(result[0].value+'-'+result[1].value+'-'+result[2].value);
            },
            title: '选择日期'
        });
    });
$('#userreg-d2').on('click', function () {
        weui.datePicker({
            start: 1990,
            end: 2025,
            onConfirm: function (result) {
               $('#userreg-d2').val(result[0].value+'-'+result[1].value+'-'+result[2].value);
            },
            title: '选择日期'
        });
    });
var _isagreeUserReg=false;
$(".userreg-c1").click(function(){
	if(false == _isagreeUserReg){
        _isagreeUserReg=true;
        $(".userreg-c1").attr("src",'images/user-reg-chek1.png');
	}else{
		_isagreeUserReg=false;
		$(".userreg-c1").attr("src",'images/user-reg-chek2.png');
	}
});
$(".phonereg-yzbtn").click(function(){
	 $(".phonereg-code").val(1234);
});
 
$(".phonereg-btn").click(function(){
	var _tel=$(".phonereg-phone").val();
	var _code=$(".phonereg-code").val();
	if('' == _tel){
		icom.alert("请输入手机号")
		return;
	}
	if('' == _code){
		icom.alert("请输入验证码")
		return;
	}
  $(".userreg-phone").html(_tel);
         $(".phonereg").hide();
         $(".userreg").show();
        return;
 
	$.post("api/?c=ishui", {p:_tel, op:'<?php echo $openid ?>'}, function(data){
			if('y' == data.s){
        alert('弹出框');
				 $(".userreg-phone").html(_tel);
				 $(".phonereg").hide();
         $(".userreg").show();
          
			}else{
				 if ('phone' == data.t) {
				 	icom.alert("手机号格式不正确")
		            return;
				 }
			}
		}, "json");	
   });

   $(".userreg-btn").click(function(){
   	   var _tel=$(".phonereg-phone").val();
   	   var _name=$(".userreg-name").val();
   	   var _yu=$(".userreg-yu").val();
   	   var _yu2=$(".userreg-yu2").val();
       
       var timeA = new Date(_yu);
       console.log(_yu2);
       
       
   	  if('' == _tel){
        $(".userreg").hide();
	    $(".phonereg").show();
   	   	return;
   	   }
   	   if ('' == _name) {
   	   	 icom.alert("请输入姓名")
		     return;
   	   }
   	   if ('' == _yu) {
   	   	 icom.alert("请输入您的预产期或宝宝生日")
		 return;
   	   }
       if ('' != _yu2) {
         var timeB = new Date(_yu2);
         var _tmpCha=Math.floor((timeB - timeA)/1000/60/60/ 24);
         console.log(_tmpCha);
         if (_tmpCha < 0) {
               icom.alert("二胎预产期，时间有误")
               return;
         }
         if (_tmpCha < 270) {
               icom.alert("二胎与一胎生日差，应大于270天")
               return;
         }
       }
   	   if(false == _isagreeUserReg){
   	   	 icom.alert("请接受会员服务条款")
		     return;
   	   }
   	   $.post("api/?c=doreg", {p:_tel,name:_name,yu:_yu,yu2:_yu2, op:'<?php echo $openid ?>'}, function(data){
			if('y' == data.s){

				  $(".userreg").hide();
          $(".gonggaobox").show();

			}else{
         icom.alert("注册失败，请检查手机格式")
         return;
      }
		}, "json");	
   	   
	  

   });



</script>